package cn.superchart.common.base;

import lombok.Data;
import lombok.Locked;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
@Data
public class BaseUserDetails implements UserDetails {

    private Collection<? extends GrantedAuthority> authorities;
    private String username;
    private String password;
    private String userId;
    private Boolean enabled = true;
    private Boolean noLocked = true;
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;
    }

    public BaseUserDetails(String username, String password, String userId , Collection<? extends GrantedAuthority> authorities) {
        this.username = username;
        this.password = password;
        this.authorities = authorities;
        this.userId = userId;
    }

    public BaseUserDetails(String username, String userId ) {
        this.username = username;
        this.userId = userId;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    public boolean isAccountNonExpired() {
        return true;
    }

    public boolean isAccountNonLocked() {
        return this.noLocked;
    }

    public boolean isCredentialsNonExpired() {
        return true;
    }

    public boolean isEnabled() {
        return this.enabled;
    }
}
